package com.laiketui.admin.store.service.dubbo;

import com.laiketui.admin.store.api.BlockHomeModelService;
import com.laiketui.common.api.PubliceService;
import com.laiketui.common.mapper.*;
import com.laiketui.common.utils.tool.DateUtil;
import com.laiketui.common.utils.tool.cache.RedisDataTool;
import com.laiketui.common.utils.tool.str.StringUtils;
import com.laiketui.core.cache.RedisUtil;
import com.laiketui.core.common.SplitUtils;
import com.laiketui.core.exception.LaiKeAPIException;
import com.laiketui.core.lktconst.GloabConst;
import com.laiketui.core.utils.tool.DataUtils;
import com.laiketui.core.utils.tool.SerializePhpUtils;
import com.laiketui.domain.dictionary.BlockHomeModel;
import com.laiketui.domain.lktconst.DictionaryConst;
import com.laiketui.domain.lktconst.ErrorCode;
import com.laiketui.domain.log.AdminRecordModel;
import com.laiketui.domain.mch.AdminModel;
import com.laiketui.domain.product.BrandClassModel;
import com.laiketui.domain.product.ProductClassModel;
import com.laiketui.domain.product.ProductMappingModel;
import com.laiketui.domain.vo.MainVo;
import com.laiketui.domain.vo.goods.GoodsConfigureVo;
import com.laiketui.domain.vo.saas.AddBlockGoodsVo;
import com.laiketui.domain.vo.saas.BlockManageVo;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;

/**
 * 楼层管理实现
 *
 * @author Trick
 * @date 2023/2/15 11:24
 */
@Service
public class BlockHomeModelServiceImpl implements BlockHomeModelService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private BlockHomeModelMapper blockHomeModelMapper;

    @Autowired
    private ProductListModelMapper productListModelMapper;

    @Autowired
    private ProductMappingModelMapper productMappingModelMapper;

    @Autowired
    private PubliceService publiceService;

    @Autowired
    private ProductClassModelMapper productClassModelMapper;

    @Autowired
    private BrandClassModelMapper brandClassModelMapper;

    @Autowired
    private ConfiGureModelMapper confiGureModelMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(BlockManageVo vo) throws LaiKeAPIException {
        try {
            AdminModel userCache = RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            int row;
            BlockHomeModel blockHomeOld = null;
            if (StringUtils.isNotEmpty(vo.getId())) {
                blockHomeOld = blockHomeModelMapper.selectByPrimaryKey(vo.getId());
            }

            BlockHomeModel blockHomeSave = new BlockHomeModel();
            blockHomeSave.setStore_id(vo.getStoreId());
            blockHomeSave.setBlock_name(vo.getName());
            blockHomeSave.setRecycle(DictionaryConst.ProductRecycle.NOT_STATUS);
            if (blockHomeOld == null || (StringUtils.isNotEmpty(vo.getName()) && !blockHomeOld.getBlock_name().equals(vo.getName()))) {
                int count = blockHomeModelMapper.selectCount(blockHomeSave);
                if (count > 0) {
                    throw new LaiKeAPIException(ErrorCode.BizErrorCode.DATA_ALREADY_EXISTS, "楼层名称已存在");
                }
            }
            if (blockHomeOld == null && StringUtils.isEmpty(vo.getName())) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "楼层名称");
            }

            blockHomeSave.setSort(vo.getSort());
            if (blockHomeOld != null) {
                blockHomeSave.setId(blockHomeOld.getId());
                row = blockHomeModelMapper.updateByPrimaryKeySelective(blockHomeSave);

                publiceService.addAdminRecord(vo.getStoreId(), "修改了楼层ID：" + blockHomeSave.getId() + "的信息", AdminRecordModel.Type.UPDATE, vo.getAccessId());
            } else {
                blockHomeSave.setAdd_date(new Date());
                row = blockHomeModelMapper.insertSelective(blockHomeSave);

                publiceService.addAdminRecord(vo.getStoreId(), "添加了楼层ID：" + blockHomeSave.getId(), AdminRecordModel.Type.ADD, vo.getAccessId());
            }

            if (row < 1) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.OPERATION_FAILED, "操作失败");
            }
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("添加/编辑楼层 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "add");
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Map<String, Object> addOrDeleteGoodsWithBlock(AddBlockGoodsVo vo) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            AdminModel userCache = RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            if (StringUtils.isEmpty(vo.getId()) || StringUtils.isEmpty(vo.getGoodsId())) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "参数错误");
            }
            BlockHomeModel blockHomeOld = blockHomeModelMapper.selectByPrimaryKey(vo.getId());
            if (blockHomeOld == null) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "楼层不存在");
            }
            //校验是否有重复的商品和商品是否存在
            Set<String> goodsIds = new HashSet<>(Arrays.asList(vo.getGoodsId().split(SplitUtils.DH)));
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", vo.getStoreId());
            parmaMap.put("goodsIdList", goodsIds);
            parmaMap.put("group_id", "group_id");
            parmaMap.put("recycle", DictionaryConst.ProductRecycle.NOT_STATUS);
            int count = productListModelMapper.countDynamic(parmaMap);
            if (count != goodsIds.size()) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "列表中有商品不存在");
            }
            //是否重复添加到楼层了
            parmaMap.put("id", vo.getId());
            count = blockHomeModelMapper.getRepeatCount(parmaMap);
            if (count > 0) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "列表中有商品已在楼层存在");
            }

            List<ProductMappingModel> productMappingModels = new ArrayList<>();
            goodsIds.forEach(id -> {
                ProductMappingModel productMappingSave = new ProductMappingModel();
                productMappingSave.setMain_id(blockHomeOld.getId());
                productMappingSave.setStore_id(vo.getStoreId());
                productMappingSave.setProduct_id(Integer.parseInt(id));
                productMappingSave.setAdd_date(new Date());
                productMappingModels.add(productMappingSave);
            });

            int row = productMappingModelMapper.insertList(productMappingModels);
            if (row < 1) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.OPERATION_FAILED, "操作失败");
            }

            publiceService.addAdminRecord(vo.getStoreId(), "将楼层ID：" + vo.getId() + "添加了商品，商品ID：" + vo.getGoodsId(), AdminRecordModel.Type.ADD, vo.getAccessId());
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("添加/编辑 楼层 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "addOrDeleteGoodsWithBlock");
        }
        return resultMap;
    }

    @Override
    public Map<String, Object> list(MainVo vo, String name) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", vo.getStoreId());

            if (StringUtils.isNotEmpty(name)) {
                parmaMap.put("likeName", name);
            }

            parmaMap.put("recycle", DictionaryConst.ProductRecycle.NOT_STATUS);
            parmaMap.put("sort_sort", DataUtils.Sort.DESC.toString());
            parmaMap.put("add_date_sort", DataUtils.Sort.DESC.toString());
            parmaMap.put("group_id", "group_id");
            parmaMap.put("pageStart", vo.getPageNo());
            parmaMap.put("pageEnd", vo.getPageSize());
            int total = blockHomeModelMapper.countDynamic(parmaMap);
            List<Map<String, Object>> list = new ArrayList<>();
            if (total > 0) {
                list = blockHomeModelMapper.selectDynamic(parmaMap);
            }

            resultMap.put("total", total);
            resultMap.put("list", list);
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("获取楼层列表 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "list");
        }
        return resultMap;
    }

    @Override
    public Map<String, Object> getBlockById(MainVo vo, String id) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            if (StringUtils.isEmpty(id)) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "参数错误");
            }
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", vo.getStoreId());
            parmaMap.put("id", id);
            parmaMap.put("group_id", "group_id");
            parmaMap.put("recycle", DictionaryConst.ProductRecycle.NOT_STATUS);
            int total = blockHomeModelMapper.countDynamic(parmaMap);
            List<Map<String, Object>> list;
            if (total > 0) {
                list = blockHomeModelMapper.selectDynamic(parmaMap);
                list.forEach(map -> {
                    resultMap.put("id", MapUtils.getString(map, "id"));
                    resultMap.put("name", MapUtils.getString(map, "block_name"));
                    resultMap.put("sort", MapUtils.getString(map, "sort"));
                });
            }

        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("单个楼层查询 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "getBlockById");
        }
        return resultMap;
    }

    @Override
    public Map<String, Object> getGoodsByBlock(MainVo vo, String id, String key, String cid, String bid, Integer tradeModel, String isPlatform, String startDate, String endDate) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        try {
            RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            if (StringUtils.isEmpty(id)) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "参数错误");
            }
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("id", id);
            parmaMap.put("store_id", vo.getStoreId());
            if (StringUtils.isNotEmpty(id)) {
                parmaMap.put("key", key);
            }
            if (StringUtils.isNotEmpty(cid)) {
                parmaMap.put("cid", cid);
            }
            if (StringUtils.isNotEmpty(bid)) {
                parmaMap.put("bid", bid);
            }
            if (tradeModel != null) {
                parmaMap.put("tradeModel", tradeModel);
            }
            if (StringUtils.isNotEmpty(isPlatform)) {
                parmaMap.put("isPlatform", isPlatform);
            }
            if (StringUtils.isNotEmpty(startDate)) {
                parmaMap.put("proStartDate", startDate);
            }
            if (StringUtils.isNotEmpty(endDate)) {
                parmaMap.put("proEndDate", endDate);
            }
            parmaMap.put("recycle", DictionaryConst.ProductRecycle.NOT_STATUS);
            parmaMap.put("sort_sort", DataUtils.Sort.DESC.toString());
            parmaMap.put("pageStart", vo.getPageNo());
            parmaMap.put("pageEnd", vo.getPageSize());
            int total = blockHomeModelMapper.countGoodsInfo(parmaMap);
            List<Map<String, Object>> list = new ArrayList<>();
            if (total > 0) {
                list = blockHomeModelMapper.selectGoodsInfo(parmaMap);
                list.forEach(map -> {
                    Integer storeId = vo.getStoreId();
                    map.put("imgUrl", publiceService.getImgPath(MapUtils.getString(map, "imgurl"), storeId));
                    String initialStr = map.get("initial").toString();
                    Map<String, String> initialMap = DataUtils.cast(SerializePhpUtils.getUnserializeObj(initialStr, Map.class));
                    if (initialMap == null) {
                        throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_SJCW, "数据错误");
                    }
                    map.put("add_date", DateUtil.dateFormate(MapUtils.getString(map, "add_date"), GloabConst.TimePattern.YMDHMS));
                    map.put("proAddDate", DateUtil.dateFormate(MapUtils.getString(map, "proAddDate"), GloabConst.TimePattern.YMDHMS));
                    BigDecimal presentPrice = new BigDecimal(initialMap.get("sj"));
                    map.put("price", presentPrice);
                    String[] productClass = org.apache.commons.collections.MapUtils.getString(map, "classId").split("-");
                    ProductClassModel productClassModel = null;
                    for (int i = 0; i < productClass.length; i++) {
                        if (i == (productClass.length - 1)) {
                            //查询下级,没有下级则查询同级
                            productClassModel = new ProductClassModel();
                            productClassModel.setStore_id(vo.getStoreId());
                            productClassModel.setCid(Integer.parseInt(productClass[i]));
                            List<ProductClassModel> productLeves = productClassModelMapper.getProductClassLevel(productClassModel);
                            //获取所有下级类别信息
                            for (ProductClassModel product : productLeves) {
                                map.put("className", product.getPname());
                            }
                            if (productLeves.size() < 0) {
                                //查询下级,没有下级则查询同级
                                productClassModel = new ProductClassModel();
                                productClassModel.setStore_id(vo.getStoreId());
                                productClassModel.setSid(Integer.parseInt(productClass[i]));
                                List<ProductClassModel> productClassLowLeves = productClassModelMapper.getProductClassLevel(productClassModel);
                                for (ProductClassModel product : productClassLowLeves) {
                                    map.put("className", product.getPname());
                                }
                            }
                        }
                    }
                });
            }
            resultMap.put("total", total);
            resultMap.put("list", list);
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("获取指定楼层下的所有商品 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "getGoodsByBlock");
        }
        return resultMap;
    }

    @Override
    public void deleteBlock(MainVo vo, String id) throws LaiKeAPIException {
        try {
            AdminModel userCache = RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            int row;
            if (StringUtils.isEmpty(id)) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "参数错误");
            }
            BlockHomeModel blockHomeModel = new BlockHomeModel();
            blockHomeModel.setStore_id(vo.getStoreId());
            blockHomeModel.setId(id);
            blockHomeModel = blockHomeModelMapper.selectOne(blockHomeModel);
            if (blockHomeModel == null) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.DATA_NOT_EXIST, "楼层不存在");
            }
            BlockHomeModel blockHomeDel = new BlockHomeModel();
            blockHomeDel.setId(id);
            blockHomeDel.setRecycle(DictionaryConst.ProductRecycle.RECOVERY);
            row = blockHomeModelMapper.updateByPrimaryKeySelective(blockHomeDel);
            if (row < 1) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.OPERATION_FAILED, "操作失败");
            }
            //删除商品
            Map<String, Object> parmaDelMap = new HashMap<>(16);
            parmaDelMap.put("mainId", id);
            productMappingModelMapper.batchDelById(parmaDelMap);

            publiceService.addAdminRecord(vo.getStoreId(), "删除了楼层ID：" + id, AdminRecordModel.Type.DEL, vo.getAccessId());
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("删除楼层及下面的商品 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "deleteBlock");
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delGoods(MainVo vo, String id, String goodsIds) throws LaiKeAPIException {
        try {
            AdminModel userCache = RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            if (StringUtils.isEmpty(goodsIds) || StringUtils.isEmpty(id)) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "参数错误");
            }
            //删除商品
            Map<String, Object> parmaDelMap = new HashMap<>(16);
            parmaDelMap.put("mainId", id);
            parmaDelMap.put("productIsList", goodsIds.split(SplitUtils.DH));
            productMappingModelMapper.batchDelById(parmaDelMap);
            publiceService.addAdminRecord(vo.getStoreId(), "将楼层ID：" + id + "的商品ID：" + goodsIds + "进行了移除",AdminRecordModel.Type.DEL, vo.getAccessId());
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("删除楼层下的商品 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "delGoods");
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void editSort(MainVo vo, int mappingId, int sort) throws LaiKeAPIException {
        try {
            ProductMappingModel productMappingUpdate = new ProductMappingModel();
            productMappingUpdate.setId(mappingId);
            productMappingUpdate.setSort(sort);
            int row = productMappingModelMapper.updateByPrimaryKeySelective(productMappingUpdate);

            if (row < 1) {
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.OPERATION_FAILED, "操作失败");
            }
        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("删除楼层下的商品 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "editSort");
        }
    }


    @Override
    public void EnableOrNot(MainVo vo, String id) throws LaiKeAPIException {
        try {
            AdminModel userCache = RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            BlockHomeModel blockHomeModel = blockHomeModelMapper.selectByPrimaryKey(id);
            if (StringUtils.isEmpty(blockHomeModel)){
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.PARAMATER_ERROR, "参数错误");
            }
            Integer enableOrNot = blockHomeModel.getEnableOrNot();
            if (enableOrNot.equals(BlockHomeModel.ENABLE_Ok)){
                enableOrNot = BlockHomeModel.ENABLE_NO;
            }else {
                enableOrNot = BlockHomeModel.ENABLE_Ok;
            }
            blockHomeModel = new BlockHomeModel();
            blockHomeModel.setId(id);
            blockHomeModel.setEnableOrNot(enableOrNot);
            int i = blockHomeModelMapper.updateByPrimaryKeySelective(blockHomeModel);
            if (i < 1){
                throw new LaiKeAPIException(ErrorCode.BizErrorCode.OPERATION_FAILED, "操作失败");
            }
            publiceService.addAdminRecord(vo.getStoreId(), "将楼层ID：" + id + "进行了是否开启操作",AdminRecordModel.Type.OPEN_OR_CLOSE, vo.getAccessId());
        }catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("楼层是否开启显示 异常 ", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "editSort");
        }

    }


    @Override
    public Map<String, Object> getSpecifiedGoodsInfo(GoodsConfigureVo vo, String id) throws LaiKeAPIException {
        Map<String, Object> resultMap = new HashMap<>(16);
        Map<String, Object> resultMap1 = new HashMap<>(16);
        try {
            AdminModel user = RedisDataTool.getRedisAdminUserCache(vo.getAccessId(), redisUtil);
            //获取商品信息
            Map<String, Object> parmaMap = new HashMap<>(16);
            parmaMap.put("store_id", vo.getStoreId());
            parmaMap.put("pageStart", vo.getPageNo());
            parmaMap.put("pageEnd", vo.getPageSize());
            parmaMap.put("mch_status", DictionaryConst.GoodsMchExameStatus.EXAME_PASS_STATUS);
            parmaMap.put("active", DictionaryConst.GoodsActive.GOODSACTIVE_POSITIVE_PRICE);
            parmaMap.put("goodsRecycle", DictionaryConst.ProductRecycle.NOT_STATUS);
            parmaMap.put("goodsStatus", DictionaryConst.GoodsStatus.NEW_GROUNDING);
            parmaMap.put("supplier_superior","supplier_superior");
            parmaMap.put("stockNum_gt", 0);
            parmaMap.put("is_presell", 0);
            //获取自营店
//            Integer mchId = customerModelMapper.getStoreMchId(vo.getStoreId());
//            parmaMap.put("mch_id", mchId);
            int[] arr = null;
            if (StringUtils.isNotEmpty(id)) {
                String[] ids = id.split(",");
                arr = new int[ids.length];
                for (int i = 0; i < ids.length; i++) {
                    arr[i] = Integer.parseInt(ids[i]);
                }
                parmaMap.put("pid", arr);
            }
            if (vo.getCid() != null) {
                parmaMap.put("product_class", vo.getCid());
            }
            if (vo.getBrandId() != null) {
                parmaMap.put("brand_id", vo.getBrandId());
            }
            if (!StringUtils.isEmpty(vo.getProductTitle())) {
                parmaMap.put("product_title", vo.getProductTitle());
            }
            if (StringUtils.isNotEmpty(vo.getBlockId())) {
                parmaMap.put("blockId", vo.getBlockId());
            }
            List<Map<String, Object>> goodsSpecifiedInfoList = productListModelMapper.getSpecifiedGoodsInfoDynamic(parmaMap);
            int total = productListModelMapper.countSpecifiedGoodsInfoDynamic(parmaMap);
            ProductClassModel productClassModel = null;
            for (Map<String, Object> map : goodsSpecifiedInfoList) {
                //获取最后一级类别
                String[] productClass = org.apache.commons.collections.MapUtils.getString(map, "product_class").split("-");
                for (int i = 0; i < productClass.length; i++) {
                    if (i == (productClass.length - 1)) {
                        //查询下级,没有下级则查询同级
                        productClassModel = new ProductClassModel();
                        productClassModel.setStore_id(vo.getStoreId());
                        productClassModel.setCid(Integer.parseInt(productClass[i]));
                        List<ProductClassModel> productLeves = productClassModelMapper.getProductClassLevel(productClassModel);
                        //获取所有下级类别信息
                        for (ProductClassModel product : productLeves) {
                            map.put("p_name", product.getPname());
                        }
                        if (productLeves.size() <= 0) {
                            //查询下级,没有下级则查询同级
                            productClassModel = new ProductClassModel();
                            productClassModel.setStore_id(vo.getStoreId());
                            productClassModel.setSid(Integer.parseInt(productClass[i]));
                            List<ProductClassModel> productClassLowLeves = productClassModelMapper.getProductClassLevel(productClassModel);
                            for (ProductClassModel product : productClassLowLeves) {
                                map.put("p_name", product.getPname());
                            }
                        }
                    }
                }
                BrandClassModel brandClassModel = brandClassModelMapper.selectByPrimaryKey(org.apache.commons.collections.MapUtils.getString(map, "brand_id"));
                map.put("brand_name", brandClassModel.getBrand_name());
                resultMap1.put("goodsId", org.apache.commons.collections.MapUtils.getString(map, "id"));
                List<Map<String, Object>> confiGureModel = confiGureModelMapper.selectDynamic(resultMap1);
                for (Map<String, Object> map1 : confiGureModel) {
                    map.put("price", org.apache.commons.collections.MapUtils.getString(map1, "price"));
                }
                //获取商品主图
                map.put("imgurl", publiceService.getImgPath(org.apache.commons.collections.MapUtils.getString(map, "imgurl"), vo.getStoreId()));
            }
            resultMap.put("list", goodsSpecifiedInfoList);
            resultMap.put("total", total);

        } catch (LaiKeAPIException l) {
            throw l;
        } catch (Exception e) {
            logger.error("获取指定商品列表 异常", e);
            throw new LaiKeAPIException(ErrorCode.BizErrorCode.ERROR_CODE_WLYC, "网络异常", "getAssignGoods");
        }
        return resultMap;
    }

}
